package main

import "fmt"

func main061() {
	fmt.Printf("12 & 10的结果：十进制%d,二进制%b\n",12 & 10,12 & 10)
	fmt.Printf("12 | 10的结果：十进制%d,二进制%b\n",12 | 10,12 | 10)
	fmt.Printf("12 ^ 10的结果：十进制%d,二进制%b\n",12 ^ 10,12 ^ 10)
}

/*
左移
*/
func main062() {

/*	//0000 1100
	var a uint8 = 12
	//0011 0000 = 48
	fmt.Println(a << 2)
	//0110 0000 = 96
	fmt.Println(a << 3)
	//1100 0000 = 192
	fmt.Println(a << 4)
	//100 00000 = 128
	fmt.Println(a << 5)*/

	//0000 1100
	var a int8 = 12
	//0011 0000
	fmt.Println(a << 2)
	//0110 0000
	fmt.Println(a << 3)
	//1100 0000 符号位为1=>负数=>补码-减一取反得到源码=>0100 0000-64=>-64
	fmt.Println(a << 4)
	//1000 0000 符号位为1=>负数=>补码-减一取反得到源码=>0100 0000-128=>-128
	fmt.Println(a << 5)
}

/*
右移
*/
func main() {

	//0000 1100
	var a uint8 = 12
	//0000 0011 = 3
	fmt.Println(a >> 2)
	//0000 0001 = 1
	fmt.Println(a >> 3)
	//0000 0000 = 0
	fmt.Println(a >> 4)
}
